/**
 * Baidu.com Inc.
 * Copyright (c) 2022 All Rights Reserved.
 */
package guaduation.dataEncapusulation;

import guaduation.enums.ResponseEnums;
import guaduation.listener.AbstractPortListener;
import guaduation.utils.HexUtil;
import guaduation.vo.CardVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author wangjiajun06
 * @version 1.0
 * @description
 * @date 2022/1/17 4:02 下午
 */
public class EncapusulationImpl extends AbstractEncapusulation<CardVO> {

    public EncapusulationImpl(byte[] data) {
        this.data = data;
        convertBytesToString();
    }

    @Override
    public CardVO encapusulation() {
        CardVO cardVO = new CardVO();
//        cardVO.setLength((int)this.data[1]);
        cardVO.setId(this.dataStr);
        return cardVO;
    }

    @Override
    public Boolean isSeccess() {
        logger.info("data:" + dataStr);
        String status = this.dataStr.substring(0, 2);
        if (ResponseEnums.SECCESS.getCode().equals(status)) {
            return true;
        } else if (ResponseEnums.FAIL.getCode().equals(status)) {
            return false;
        } else {
            return false;
        }
    }
}

